import java.util.*;

 class TreeNode {
     int val = 0;
     TreeNode left = null;
     TreeNode right = null;

     public TreeNode(int val) {
         this.val = val;

     }

     class Info {
         TreeNode findans;
         boolean findo1;
         boolean findo2;

         public Info(TreeNode ansi, boolean o1, boolean o2) {
             this.findans = ansi;
             this.findo1 = o1;
             this.findo2 = o2;
         }
     }

     public class TextDemo {
         public Info ans(TreeNode root, int o1, int o2) {
             if (root == null) {
                 return new Info(null, false, false);
             }

             Info leftInfo = ans(root.left, o1, o2);
             Info rightInfo = ans(root.right, o1, o2);

             if (leftInfo.findans != null) {
                 return new Info(leftInfo.findans, true, true);
             }

             if (rightInfo.findans != null) {
                 return new Info(rightInfo.findans, true, true);
             }

             //左右两树都没发现公共祖先
             if (leftInfo.findo1 && rightInfo.findo2) {
                 return new Info(root, true, true);
             }
             if (leftInfo.findo2 && rightInfo.findo1) {
                 return new Info(root, true, true);
             }
             boolean findo1 = root.val == o1;
             boolean findo2 = root.val == o2;
             if (leftInfo.findo1 || rightInfo.findo2) {
                 if (findo2) {
                     return new Info(root, true, true);
                 } else {
                     return new Info(null, true, false);
                 }
             }
             if (leftInfo.findo2 || rightInfo.findo2) {
                 if (findo1) {
                     return new Info(root, true, true);
                 } else {
                     return new Info(null, false, true);
                 }
             }
             return new Info(null, false, false);
         }

         public int lowestCommonAncestor(TreeNode root, int o1, int o2) {
             // write code here
             Info i = ans(root, o1, o2);
             return i.findans.val;
         }

         TreeNode Deserialize(String str) {
             if (str == null) {
                 return null;
             }
             Queue<String> queue = new LinkedList<>();
             for (int i = 0; i < str.length(); i++) {
                 queue.offer(str.charAt(i) + "");
             }
             return ans(queue);

         }

         public TreeNode ans(Queue<String> queue) {
             if (queue.isEmpty() || queue.peek() == "#") {
                 return null;
             }
             TreeNode head = new TreeNode(Integer.parseInt(queue.poll()));
             head.left = ans(queue);
             head.right = ans(queue);
             return head;
         }



     }

     public static void main(String[] args) {
         Queue<String> queue = new LinkedList<>();
         System.out.println(queue.peek());

     }
 }